package topic.impl;

import interfaces.Subscriber;
import interfaces.impl.SubscriberImpl;

import java.rmi.RemoteException;

import accessers.DataReader;
import accessers.impl.DataReaderImpl;
import data.DataObject;
import topic.Topic;

public class TopicImpl implements Topic {
	private String name = null;
	private DataObject data = null;
	private DataReader dataReader = null;
	private Subscriber subscriber = null;
	
	public TopicImpl(String name) {
		this.name = name;
		this.dataReader = new DataReaderImpl(this);
		this.subscriber = new SubscriberImpl();
		this.subscriber.setDataReaderListener(dataReader);
	}
	
	public TopicImpl(String name, DataObject data) {
		this(name);
		this.data.setData(data.getData());
	}

	public DataObject getDataObject() throws RemoteException {
		return data;
	}

	public void setDataObject(DataObject data) throws RemoteException {
		this.data = data;
	}

	public String getName() throws RemoteException {
		return name;
	}

	public Subscriber getSuscriber() throws RemoteException {
		return subscriber;
	}

	public DataReader getDataReader() throws RemoteException {
		return dataReader;
	}

}
